import React, { Component } from 'react'

export default class App extends Component {
  state = {
    age: 18,
  }
  handleClick = () => {
    this.setState(
      {
        age: this.state.age + 1,
      },
      () => {
        // 这里可以拿到更新之后的数据
        console.log(this.state.age)
      }
    )
  }
  render() {
    return (
      <div>
        <p>{this.state.age}</p>
        <button onClick={this.handleClick}>+1</button>
      </div>
    )
  }
}
